package com.ruoyi.hualian.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hualian.domain.HlDeliveryTime;
import com.ruoyi.hualian.service.IHlDeliveryTimeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 货期Controller
 * 
 * @author hujian
 */
@RestController
@RequestMapping("/hualian/delivery")
public class HlDeliveryTimeController extends BaseController
{
    @Autowired
    private IHlDeliveryTimeService hlDeliveryTimeService;

    /**
     * 查询货期列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:delivery:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlDeliveryTime hlDeliveryTime)
    {
        startPage();
        List<HlDeliveryTime> list = hlDeliveryTimeService.selectHlDeliveryTimeList(hlDeliveryTime);
        return getDataTable(list);
    }

    /**
     * 导出货期列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:delivery:export')")
    @Log(title = "货期", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlDeliveryTime hlDeliveryTime)
    {
        List<HlDeliveryTime> list = hlDeliveryTimeService.selectHlDeliveryTimeList(hlDeliveryTime);
        ExcelUtil<HlDeliveryTime> util = new ExcelUtil<HlDeliveryTime>(HlDeliveryTime.class);
        util.exportExcel(response, list, "货期数据");
    }

    /**
     * 获取货期详细信息
     */
    @PreAuthorize("@ss.hasPermi('hualian:delivery:query')")
    @GetMapping(value = "/{deliveryId}")
    public AjaxResult getInfo(@PathVariable("deliveryId") Long deliveryId)
    {
        return success(hlDeliveryTimeService.selectHlDeliveryTimeByDeliveryId(deliveryId));
    }

    /**
     * 新增货期
     */
    @PreAuthorize("@ss.hasPermi('hualian:delivery:add')")
    @Log(title = "货期", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlDeliveryTime hlDeliveryTime)
    {
        return toAjax(hlDeliveryTimeService.insertHlDeliveryTime(hlDeliveryTime));
    }

    /**
     * 修改货期
     */
    @PreAuthorize("@ss.hasPermi('hualian:delivery:edit')")
    @Log(title = "货期", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlDeliveryTime hlDeliveryTime)
    {
        return toAjax(hlDeliveryTimeService.updateHlDeliveryTime(hlDeliveryTime));
    }

    /**
     * 删除货期
     */
    @PreAuthorize("@ss.hasPermi('hualian:delivery:remove')")
    @Log(title = "货期", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deliveryIds}")
    public AjaxResult remove(@PathVariable Long[] deliveryIds)
    {
        return toAjax(hlDeliveryTimeService.deleteHlDeliveryTimeByDeliveryIds(deliveryIds));
    }
}
